# https://www.byhy.net/etc/hyuiauto/02/

from time import sleep
from hyuiauto import AndroidConnector

ac = AndroidConnector()

device = ac.device(manufacturer='samsung', model=None, sn=None)

# 打开支付宝首页
device.openApp('com.eg.android.AlipayGphone')

device.tapTextOnScreen('我的小程序', exact=False)

# device.waitForTextOnScreen('支付宝公益')

device.tapTextOnScreen('支付宝公益', range=(39, 401, 1008, 1100))
sleep(3)

# 点击搜索图标
device.tap(1000, 300)
sleep(2)

# 点击左上角搜索框里面的搜索
device.tapTextOnScreen('搜索', range=(8, 262, 298, 409))
sleep(1)

device.inputString('困难家庭')
sleep(1)

# 点击右上角搜索
device.tapTextOnScreen('搜索', range=(823, 170, 1072, 519))

sleep(2)

# 打印搜索结果
txt = device.screenToText(range=(5, 427, 1065, 2254))
print(txt)
